<template>
	<view class="main-view">
		<prompt ref="prompt" @onConfirm="onConfirm" @onCancel="onCancel" title="提示" :text="'请输入拒绝理由:'"></prompt>
		<view class="user-item dashboard"><text class="item-name">状态</text><text class="item-content" v-bind:style="{color:(status==0?'rgb(168, 180, 77)':(status==1?'green':'red'))}">{{tranUtil.tranUtil.enrollDataStatusTran(status)}}</text></view>
		<view class="user-item dashboard" @click="showUser=!showUser"><text class="item-name">用户名</text><text class="item-content">{{username}}</text></view>

		<view v-show="showUser" class="col-arrange" style="width:98%;margin-left:1%;">
			<view class="user-item dashboard"><text class="item-name">真实姓名</text><text class="item-content">{{user.name}}</text></view>
			<view class="user-item dashboard" style="height:250upx;"><text class="item-name">个人介绍</text><text style="margin-top:50upx;margin-left:1%">{{user.intro}}</text></view>
			<view class="user-item dashboard"><text class="item-name">加入时间</text><text class="item-content">{{user.joinTime}}</text></view>
			<view class="user-item dashboard"><text class="item-name">加入方式</text><text class="item-content">{{tranUtil.tranUtil.joinMetTran(user.joinMet)}}</text></view>
			<view class="user-item dashboard"><text class="item-name">身份</text><text class="item-content">{{tranUtil.tranUtil.identifyTran(user.identify)}}</text></view>
		</view>
		<view v-if="checkTime.length > 0" class="user-item"><text class="item-name">审核时间</text><text class="item-content">{{checkTime}}</text></view>
		<view v-if="rejectReason.length > 0" class="user-item" style="height:250upx;"><text class="item-name">拒绝理由</text><text class="intro-content">{{rejectReason}}</text></view>
		<view class="col-arrange" style="margin-bottom:20upx;">
		<view class="user-item dashboard" @click="showAns=!showAns"><text class="item-name">报名信息，点击查看</text></view>
		<zEnrollAnsPanel v-show="showAns" style="width:98%;margin-left:1%;" :answer="content"/>
		</view>
		
		
		<!-- <view v-if="status == '审核中'"> -->
			<button style="background-color:green;margin-bottom:15upx;" type="primary" v-if="status == 0" @click="pass" class="check-button">通过</button>
			<button style="background-color:red" type="primary" v-if="status == 0" @click="reject" class="check-button">拒绝</button>
		<!-- </view> -->
		
	</view>
</template>
	
	

<script>
	import formatDatetime from "../../common/zdateutil.js"
	import tranUtil from "../../common/znumtranutil.js"
	import zEnrollAnsPanel from "../../components/basic/zenrollanspanel";
	import prompt from '../../components/basic/prompt';
	export default {
		
		data() {
			return {
				content : [],
				status : "",
				submitTime : "",
				checkTime : "",
				rejectReason : "",
				eId : "",
				username : "",
				promptText : "",
				user : {},
				tranUtil : null,
				showUser : false,
				showAns : false
			}
		},
		components : {
			zEnrollAnsPanel,
			prompt
		},
		onLoad : function(option) {
			// console.log(option.username);
			// console.log(option.eId);
			this.tranUtil = tranUtil;
			var param = {'username':option.username,'eId':option.eId}
			this.eId = option.eId;
			this.username = option.username;
			var vm = this;
			// 获取用户填写的报名数据
			this.$get(this.enrollurl + '/enroll/enrollDataDetail',param,function(res){
				var data = res.data;
				if(data.code != 0){
					uni.showModal({
						title : '错误',
						content : data.message,
						showCancel : false
					})
				}
				var obj = data.object;
				vm.content = JSON.parse(obj.content);
				vm.status = obj.status;
				vm.submitTime = formatDatetime.formatDatetime(new Date(obj.submitTime));
				
				if(obj.status != 0 && obj.status != 3){
					vm.checkTime = formatDatetime.formatDatetime(new Date(obj.checkTime));
				}
				if(obj.status == 2){
					vm.rejectReason = obj.rejectReason;
				}
			});
			// 获取用户个人数据
			param = {'username':option.username};
			this.$get(this.userurl + '/user/getOther',param,function(res){
				var data = res.data;
				if(data.code != 0){
					uni.showModal({
						title : '错误',
						content : data.message,
						showCancel : false
					})
				}
				vm.user = data.object;
				vm.user.joinTime = formatDatetime.formatDatetime(new Date(data.object.joinTime));
				// vm.user.intro = '哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦'
			});
			

		},
		methods: {
			prompt:function(){
				this.$refs.prompt.show();
			},
			pass : function(){
				console.log(this.eId)
				var param = {'eId':this.eId,'username':this.username,'status':1,'rejectReason':''};
				var vm = this;
				this.$post(this.enrollurl + '/enroll/updateDataStatus',param,function(res){
					var data = res.data;
					uni.showModal({
						title : '错误',
						content : data.message,
						showCancel : false
					})
					uni.navigateTo({
						url : 'enrollManagePage?id=' + vm.eId
					})
				});
			},
			reject : function(){
				this.$refs.prompt.show();
			},
			onConfirm : function(){
				var param = {'eId':this.eId,'username':this.username,'status':2,'rejectReason':this.$refs.prompt.cost};
				var vm = this;
				this.$post(this.enrollurl + '/enroll/updateDataStatus',param,function(res){
					var data = res.data;
					uni.showModal({
						title : '错误',
						content : data.message,
						showCancel : false
					})
					uni.navigateTo({
						url : 'enrollManagePage?id=' + vm.eId
					})
				});
			},
			onCancel:function(){
				this.$refs.prompt.hide();
				this.$refs.prompt.cost = '';
			},
			userInfo : function(){
				// console.log(this.username)
				uni.navigateTo({
					url : '../user/info?userId=' + this.username
				})
			}
			
		}
	}
</script>

<style>
	@import "../../common/zcss.css";
	.main-view{
		width: 100%;
		flex-direction: column;
	}
	.check-button{
		width: 90%;
	}
	.user-item{
		border: 1upx solid gray;
		
		/* border-top: 1upx solid gray; */
		width: 99%;
		height:50upx;
		padding-top: 10upx;
		/* background-color: white; */
		position: relative;
	}
	.item-name{
		position: absolute;
		left: 1%;
		color: gray;
	}
	.item-content{
		position: absolute;
		right: 1%;
	
	}
	.intro-content{
		margin-top:50upx;
		margin-left:1%;
		position: absolute;
		/* width: */
		/* right: 1%; */
	}
</style>
